<?php
require_once(dirname(__FILE__).'/inc/header.php');

$data_login = new data_login();
$uid = $data_login->login_by_qqwb_openkey($_GET['openid'], $_GET['openkey']);

if ($uid) {
	$url = 'http://uread.me/?from=qqwb';
	
	echo loadMod('glob/header');
	
	$data_user = new data_user();
	$me = $data_user->one($uid);
	echo '
	<div class="nav" style="padding:0 20px;">
		<a href="'.$url.'" target="_blank">
			<span class="u">uRead</span>
			<span class="dot">•</span>
			<span class="me">Me</span>
		</a>
		<span style="float:right; padding-top:15px;">
			<a class="nk" href="'.$url.'" target="_blank">'.$me['nickname'].'</a> 
		</span>
	</div>
	';
	
	if ($data_user->is_show_extension_tip($uid)) {
		echo '
			<div style="background-color:#ACF; height:220px;">
				<div style="float:right; padding:20px;">
					<a href="'.$url.'" target="_blank">
						<img id="home_ext_img" src="about:blank;" width="320" style="border:1px solid #FFF;">
					</a>
				</div>
				<div style="margin-right: 350px; padding:20px 0 20px 20px;">
					<div style="font:bold 18px 微软雅黑; color: #FFF; padding:10px 0 0 0; ">
						uReadMe网文摘手<br>
						<span id="home_ext_txt" style="font:14px 微软雅黑; color:#FFF; margin-left:10px;"></span>
					</div>
					<div style="padding:20px 0 0 30px;">
						<li style="font:14px 微软雅黑; color:#FFF; margin-bottom: 3px;">在上网时发现了好文章、好图片，一键保存下来</li>
						<li style="font:14px 微软雅黑; color:#FFF; margin-bottom: 3px;">在阅读圈中与好友分享</li>
						<li style="font:14px 微软雅黑; color:#FFF; margin-bottom: 3px;">点名推荐给好友，免得他错过了精彩 :D</li>
					</div>
					<div style="text-align:right; padding:20px 20px 0 0;">
						<a href="'.$url.'" target="_blank" style="font:14px 微软雅黑; color:#FFF; text-decoration: underline;">了解详情</a>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
				new function () {
					if ($.browser.msie) {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_ie9_5.gif");
						$("#home_ext_txt").html("(IE收藏夹快捷方式)");
					} else if ($.browser.mozilla) {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_ff_1.gif");
						$("#home_ext_txt").html("(火狐浏览器扩展 Firefox Extension)");
					} else if ($.browser.chrome) {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_cr_1.gif");
						$("#home_ext_txt").html("(谷歌浏览器扩展 Chrome Extension)");
					} else if ($.browser.opera) {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_cr_1.gif");
						$("#home_ext_txt").html("");
					} else if ($.browser.safari) {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_cr_1.gif");
						$("#home_ext_txt").html("");
					} else if ($.browser.webkit) {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_cr_1.gif");
						$("#home_ext_txt").html("(谷歌浏览器扩展 Chrome Extension)");
					} else {
						$("#home_ext_img").attr("src", "http://uread.me/images/ext_ie9_5.gif");
						$("#home_ext_txt").html("(IE收藏夹快捷方式)");
					}
				};
				</script>
			</div>
		';
	}

	// recommend
	$data_recommend_article = new data_recommend_article();
	$recommend = $data_recommend_article->ls($uid, 'unread', 0, 1, 10);
	if (is_array($recommend)) {
		echo '<div class="recommend" style="margin:20px;">';
		echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
		foreach ($recommend as $v) {
			echo '
			<tr class="it" onmouseover="$(this).addClass(\'hover\');" onmouseout="$(this).removeClass(\'hover\');">
				<td width="70">
					<a class="usr" href="'.$url.'" target="_blank">'.$v['friend_nickname'].'</a>
				</td>
				<td width="70" align="center">
					<span class="txt">推荐文章</span>
				</td>
				<td>
					<a href="'.$url.'" target="_blank" class="article" style="font-size:14px;">'.$v['article_title'].'</a>
				</td>
				<td width="100" align="right">
					<span class="txt">('.substr($v['dt'], 5, 11).')</span>
				</td>
			</tr>
			';
		}
		echo '</table>';
		echo '</div>';
	}

	// circle/follow article
	$data_save_article = new data_save_article();
	$articles = $data_save_article->ls_tee($uid, 0, 1, 20);
	if (is_array($articles)) {
		echo '<div class="block" style="padding:0 40px 0 20px;">';
		echo '<div id="circle_article_list" class="article_list">';
		foreach ($articles as $v) {
			echo '
				<div class="item" onmouseover="$(this).addClass(\'hover\');" onmouseout="$(this).removeClass(\'hover\');">
					<div class="row1">
						<div class="dt">
							'.substr($v['dt'], 5, 11).'
						</div>
						<div class="txt">
							<a href="'.$url.'" target="_blank">'.$v['user_nickname'].'</a>
							<span>保存到</span>';
			if (is_array($v['circles'])) {
				$tmp = array();
				foreach ($v['circles'] as $c) {
					$tmp[] = '<a href="'.$url.'" target="_blank" >'.$c['title'].'</a>';
				}
				echo implode('、', $tmp);
			}
			echo '
						</div>
					</div>
					<div class="row2">
						<a class="link" href="'.$v['url'].'" target="_blank">
							'.$v['url'].'
						</a>
						<a class="title" href="'.$url.'" target="_blank">
							'.$v['title'].'
						</a>
					</div>
				</div>
			';
		}
		echo '</div>';
		echo '</div>';
	} else {
		echo '<div class="content" style="color:#777; padding:50px 0; text-align: center; font-size: 14px;">没有内容？那先试一试“网文摘手”，用它给你的好友推荐几篇好文章吧！</div>';
	}
} else {
	// 没有登录
}


require_once(dirname(__FILE__).'/inc/footer.php');
?>